Choose Your Own Adventure Type Provider

:: fsharp, type providers

That's right.. the type provider everyone has been waiting for, the choose your own adventure type provider!

This is completely pointless and silly, something I just wrote this afternoon. I had various discussions with Phil Trelford about this and finally decided to do it.

Unfortunately none of the real CYOA books are out of copyright and there appears to be very little in the way of other free ones that I can find. I did however find this onerather silly story on smashwords which is free, it's not quite normal CYOA fare and you can't lose, but it serves to illustrate the provider.

The provider reads a data file which contains the contents of each page on a line, the index of the page and any choices the page has on it along with the index that each choice points to. This then creates a type system with properties that you can navigate via intellisense.

1
2
3
4
5
6
#r @"F:\dropbox\CYOAProvider\CYOAProvider\bin\Debug\CYOAProvider.dll "
type adventure = CYOAProvider.CYOAProvider< @"F:\dropbox\CYOAProvider\data.dat">

let a = adventure()

a.Intro  // start your adventure here!

You can find this ridiculous type provider on GitHub here.

To create the data file I wrote an amazing C# GUI, if you want to create a file yourself and would like the program to work with then mail me :)